package com.example.frickytest;

import android.content.Context;
import android.content.res.TypedArray;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Gallery;
import android.widget.ImageView;

public class myImageAdapter extends BaseAdapter {

	int mGalleryItemBackground;
	private Context context;

	public Integer[] myImageIds = { R.drawable.photo1, R.drawable.photo2,
			R.drawable.photo3, R.drawable.photo4, R.drawable.photo5,
			R.drawable.photo6, };

	public myImageAdapter(Context context) {

		this.context = context;

		TypedArray typed_array = context
				.obtainStyledAttributes(R.styleable.Gallery);

		mGalleryItemBackground = typed_array.getResourceId(
				R.styleable.Gallery_android_galleryItemBackground, 0);

		typed_array.recycle();
	}

	public int getCount() {

		return myImageIds.length;
	}

	public Object getItem(int position) {

		return position;
	}

	public long getItemId(int position) {

		return position;
	}

	@SuppressWarnings("deprecation")
	public View getView(int position, View convertView, ViewGroup parent) {

		ImageView imageview = new ImageView(context);

		imageview.setImageResource(myImageIds[position]);

		imageview.setLayoutParams(new Gallery.LayoutParams(128, 128));

		imageview.setBackgroundResource(mGalleryItemBackground);

		return imageview;
	}
}